package com.grep.extra.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.grep.base.db.DBUtils;
import com.grep.extra.factory.handle.impl.ContentHandler;
import com.grep.extra.factory.handle.impl.ContentUrlHandler;
import com.grep.extra.factory.handle.impl.SiteUrlHandler;
import com.grep.extra.factory.handle.impl.TaskUrlHandler;
import com.grep.extra.factory.utils.FileLoaderUtil;
import com.grep.extra.service.CollectTask;

public class TaskStart {
	
	static final  Logger logger = LoggerFactory.getLogger(TaskStart.class);
    
	 /**
	  * the system start
	  * @param args no parameter
	  */
	public static void main(String[] args) {
		
		String dbconfig = "config/dbconfig.properties" ;		
		String logconfig = "config/logback.xml" ;
		 
		logger.info("the dbconfig file at {},and the application will loading ...",dbconfig); 
		logger.info("the logconfig file at {},and the application will loading ...",logconfig); 
		FileLoaderUtil.resetLogProperties(logconfig);
		logger.info("application loadin log config is OK!"); 
		DBUtils.setPro(FileLoaderUtil.loadDatabaseProperties(dbconfig)) ;
		DBUtils.init() ; 
		logger.info("application loadin database config is OK!"); 
		//总的调度器，控制程序的执行流程
		CollectTask collecter = new CollectTaskImpl() ;
		//分析处理网站任务中，所有的
		collecter.discoveryTaskUrl(new SiteUrlHandler());
		collecter.discoveryTaskContentUrl(new TaskUrlHandler()) ;
		collecter.discoveryPageContent(new ContentUrlHandler());
		collecter.discoveryContent(new ContentHandler()) ;
	}

}
